package org.example.gxpt.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.example.gxpt.common.result.PageResult;
import org.example.gxpt.mapper.InstrumentMapper;
import org.example.gxpt.pojo.dto.InstrumentPageQueryDTO;
import org.example.gxpt.pojo.vo.InstrumentQueryVO;
import org.example.gxpt.service.InstrumentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class InstrumentServiceImpl implements InstrumentService {

    @Autowired
    private InstrumentMapper instrumentMapper;

    @Override
    public List<InstrumentQueryVO> listAll() {
        return instrumentMapper.listAll();
    }

    @Override
    public PageResult page(InstrumentPageQueryDTO instrumentPageQueryDTO) {
        PageHelper.startPage(instrumentPageQueryDTO.getPage(), instrumentPageQueryDTO.getPageSize());

        Page<InstrumentQueryVO> page = instrumentMapper.pageQuery(instrumentPageQueryDTO);
        return new PageResult(page.getTotal(), page.getResult());
    }

    @Override
    public InstrumentQueryVO getInstrumentById(Long id) {
        return instrumentMapper.getById(id);
    }


}
